package com.tistory.admin.common;

import javax.servlet.http.HttpServletResponse;
import org.apache.struts2.StrutsStatics;
import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionInvocation;
import com.opensymphony.xwork2.interceptor.AbstractInterceptor;

public class CachingHeadersInterceptor extends AbstractInterceptor {
	private static final long serialVersionUID = 1L;

	public String intercept( ActionInvocation invocation) throws Exception {
		final ActionContext context = invocation.getInvocationContext();

		HttpServletResponse response = (HttpServletResponse)context.get(StrutsStatics.HTTP_RESPONSE);
		if( response != null ) {
			/*response.setHeader("Cache-control","no-cache, no-store");
			response.setHeader("pragma","cache");
			response.setHeader("Expires","-1");*/
			
			response.setHeader("Pragma", "public"); //added
			response.setHeader("Expires", "0"); //added
			response.setHeader("Cache-Control", "must-revalidate, post-check=0, pre-check=0"); //added
			response.setHeader("Cache-Control", "public"); //added
			response.setHeader("Content-Description", "File Transfer"); //added

			response.setHeader("Content-Transfer-Encoding", "binary"); //added

		}

		return invocation.invoke();
	}
}